package com.thread.exe;

//暴躁的有界队列
public class GrumpyBoundedBuffer<V> extends BaseBoundedBuffer<V>{

	private static final long SLEEP_TIME = 10L;

	protected GrumpyBoundedBuffer(int capacity) {
		super(capacity);
	}

	public synchronized void put(V v) {
		if(isFull())
			throw new IllegalStateException();
		doPut(v);
	}
	
	public synchronized V take() {
		if(isEmpty())
			throw new IllegalStateException();
		return doTake();
	}
	
	@SuppressWarnings("unused")
	public void test() throws InterruptedException {
		while(true) {
			try {
				V item = take();
				//对item的操作
				break;
			} catch (Exception e) {
				Thread.sleep(SLEEP_TIME);
			}
		}
	}
}
